package de.openlaboratory.cmis.repository;

import java.io.File;
import java.nio.file.Path;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.chemistry.opencmis.client.api.CmisObject;
import org.apache.chemistry.opencmis.client.api.FileableCmisObject;
import org.apache.chemistry.opencmis.client.api.Folder;
import org.apache.chemistry.opencmis.client.api.ObjectId;
import org.apache.chemistry.opencmis.client.api.ObjectType;
import org.apache.chemistry.opencmis.client.api.OperationContext;
import org.apache.chemistry.opencmis.client.api.Policy;
import org.apache.chemistry.opencmis.client.api.Property;
import org.apache.chemistry.opencmis.client.api.Relationship;
import org.apache.chemistry.opencmis.client.api.Rendition;
import org.apache.chemistry.opencmis.client.api.SecondaryType;
import org.apache.chemistry.opencmis.client.api.TransientCmisObject;
import org.apache.chemistry.opencmis.commons.data.Ace;
import org.apache.chemistry.opencmis.commons.data.Acl;
import org.apache.chemistry.opencmis.commons.data.AllowableActions;
import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement;
import org.apache.chemistry.opencmis.commons.data.Properties;
import org.apache.chemistry.opencmis.commons.enums.AclPropagation;
import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
import org.apache.chemistry.opencmis.commons.enums.ExtensionLevel;

public class LocalFile implements FileableCmisObject
{
	private Path path;
	private Properties props;
	private Map<String, Property<?>> properties;

	public LocalFile(Path p)
	{
		this.path = p;

		Map<String, Object> properties = new HashMap<String, Object>();

		properties.put("FULL_PATH", this.path.toAbsolutePath().toString());
		properties.put("my:int.property", 42);
		properties.put("my:date.property", new GregorianCalendar());
		properties.put("my:bool.property", true);
		
		this.updateProperties(properties);
	}

	@Override
	public String getId()
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<ObjectType> findObjectType(String arg0)
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public ObjectType getBaseType()
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public BaseTypeId getBaseTypeId()
	{
		File fileRep = path.toFile();
		if (fileRep.isDirectory())
		{
			return BaseTypeId.CMIS_FOLDER;
		}
		else if(fileRep.isFile())
		{
			return BaseTypeId.CMIS_DOCUMENT;
		}
		else
		{
			return BaseTypeId.CMIS_ITEM;
		}
	}

	@Override
	public String getChangeToken()
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getCreatedBy()
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public GregorianCalendar getCreationDate()
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getDescription()
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public GregorianCalendar getLastModificationDate()
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getLastModifiedBy()
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getName()
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Property<?>> getProperties()
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public <T> Property<T> getProperty(String s)
	{
		if(props.getProperties().containsKey(s))
		{
			Property<T> p = (Property<T>) props.getProperties().get(s);
			return p;
		}
		else
			return null;
	}

	@Override
	public <T> T getPropertyValue(String arg0)
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<SecondaryType> getSecondaryTypes()
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public ObjectType getType()
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Acl addAcl(List<Ace> arg0, AclPropagation arg1)
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Acl applyAcl(List<Ace> arg0, List<Ace> arg1, AclPropagation arg2)
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void applyPolicy(ObjectId... arg0)
	{
		// TODO Auto-generated method stub

	}

	@Override
	public void delete()
	{
		// TODO Auto-generated method stub

	}

	@Override
	public void delete(boolean arg0)
	{
		// TODO Auto-generated method stub

	}

	@Override
	public Acl getAcl()
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public <T> T getAdapter(Class<T> arg0)
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public AllowableActions getAllowableActions()
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<CmisExtensionElement> getExtensions(ExtensionLevel arg0)
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Policy> getPolicies()
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getRefreshTimestamp()
	{
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public List<Relationship> getRelationships()
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Rendition> getRenditions()
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	@Deprecated
	public TransientCmisObject getTransientObject()
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void refresh()
	{
		// TODO Auto-generated method stub

	}

	@Override
	public void refreshIfOld(long arg0)
	{
		// TODO Auto-generated method stub

	}

	@Override
	public Acl removeAcl(List<Ace> arg0, AclPropagation arg1)
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void removePolicy(ObjectId... arg0)
	{
		// TODO Auto-generated method stub

	}

	@Override
	public Acl setAcl(List<Ace> arg0)
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public CmisObject updateProperties(Map<String, ?> arg0)
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public ObjectId updateProperties(Map<String, ?> arg0, boolean arg1)
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void addToFolder(ObjectId arg0, boolean arg1)
	{
		// TODO Auto-generated method stub
		
	}

	@Override
	public List<Folder> getParents()
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Folder> getParents(OperationContext arg0)
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<String> getPaths()
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public FileableCmisObject move(ObjectId arg0, ObjectId arg1)
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public FileableCmisObject move(ObjectId arg0, ObjectId arg1, OperationContext arg2)
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void removeFromFolder(ObjectId arg0)
	{
		// TODO Auto-generated method stub
		
	}

}
